<template>
	<view>
		<u-sticky>
			<u-alert :title="'为您找到以下共'+searchTotal+'条搜索结果'" type="success" :show-icon="true"></u-alert>
		</u-sticky>
		<view v-if="searchTotal>0">
			<!-- 视频列表自定义组件 -->
			<videolist :videoList="videoList"></videolist>
		</view>

		<view style="margin-top: 200rpx;" v-else>
			<u-empty mode="search" icon="http://cdn.uviewui.com/uview/empty/search.png">
			</u-empty>
		</view>
	</view>
</template>

<script>
	const db = uniCloud.database();
	const _ = db.command;
	import videolist from '@/components/videolist/videolist.vue';
	export default {
		components: {
			videolist,
		},
		data() {
			return {
				videoList: [],
				searchTotal: 0,
			}
		},
		async onLoad(options) {
			if (!options.keyword) {
				console.log("无关键词");
				return;
			}
			let searchData = await db.collection('a_tv').where({
				tv_name: new RegExp(options.keyword)
			}).get()
			this.videoList = searchData.result.data;
			this.searchTotal = searchData.result.data.length

		},
		methods: {

		}
	}
</script>

<style>

</style>
